package com.hzhr.iot.device.convertor;

import com.hzhr.iot.device.convertor.custom.*;
import com.hzhr.iot.core.util.HzhrTypeUtil;
import com.hzhr.iot.core.util.HzhrJsonUtil;
import java.util.Map;
import com.hzhr.iot.device.entity.DeviceInfoCardEntity;
import com.hzhr.iot.device.entity.ext.DeviceInfoCardEntityExt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.hzhr.iot.device.model.regulatorDevice_infoCard.RegulatorDevice_InfoCardModel;
import com.hzhr.iot.device.model.regulatorDevice_infoCard.RegulatorDevice_InfoCardGetModel;
import com.hzhr.iot.device.model.regulatorDevice_infoCard.RegulatorDevice_InfoCardPutModel;
import com.hzhr.iot.device.queryModel.custom.DeviceInfoCardCustomQueryModel;

@Component
public class DeviceInfoCardConvertor {
    @Autowired
    AlarmDataCustomConvertor alarmDataCustomConvertor;
    @Autowired
    CollectDataCustomConvertor collectDataCustomConvertor;
    @Autowired
    CollectDeviceCustomConvertor collectDeviceCustomConvertor;
    @Autowired
    CollectDeviceTypeCustomConvertor collectDeviceTypeCustomConvertor;
    @Autowired
    DeviceMaintenanceCardCustomConvertor deviceMaintenanceCardCustomConvertor;
    @Autowired
    DeviceMaintenanceCardItemCustomConvertor deviceMaintenanceCardItemCustomConvertor;
    @Autowired
    ImplFactoryCustomConvertor implFactoryCustomConvertor;
    @Autowired
    ImplIotDeviceTypeCustomConvertor implIotDeviceTypeCustomConvertor;
    @Autowired
    ImplRecordCustomConvertor implRecordCustomConvertor;
    @Autowired
    IotDeviceCustomConvertor iotDeviceCustomConvertor;
    @Autowired
    IotDeviceTypeCustomConvertor iotDeviceTypeCustomConvertor;
    @Autowired
    OptionsCustomConvertor optionsCustomConvertor;
    @Autowired
    ProdFactoryCustomConvertor prodFactoryCustomConvertor;
    @Autowired
    RegulatorCollectDataCustomConvertor regulatorCollectDataCustomConvertor;
    @Autowired
    UserCompanyCustomConvertor userCompanyCustomConvertor;

    public DeviceInfoCardEntity regulatorDevice_InfoCardModel2entity(RegulatorDevice_InfoCardModel in) {
        //未转换字段: createUserId updateUserId isValid outId updateTime state 
        if (in == null) return null;
        DeviceInfoCardEntity result = new DeviceInfoCardEntity();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setRuningPressure(HzhrTypeUtil.double2double(in.getRuningPressure()));
        result.setMainClosePressure(HzhrTypeUtil.double2double(in.getMainClosePressure()));
        result.setSecondClosePressure(HzhrTypeUtil.double2double(in.getSecondClosePressure()));
        result.setOffPressure(HzhrTypeUtil.double2double(in.getOffPressure()));
        result.setEscapePressure(HzhrTypeUtil.double2double(in.getEscapePressure()));
        result.setSafetyDevice(HzhrTypeUtil.string2string(in.getSafetyDevice()));
        result.setPegCount(HzhrTypeUtil.integer2integer(in.getPegCount()));
        result.setResidentCustomerCount(HzhrTypeUtil.integer2integer(in.getResidentCustomerCount()));
        result.setCommercialCustomerCount(HzhrTypeUtil.integer2integer(in.getCommercialCustomerCount()));
        result.setCollectiveCustomerCount(HzhrTypeUtil.integer2integer(in.getCollectiveCustomerCount()));
        result.setIndustrialCustomerCount(HzhrTypeUtil.integer2integer(in.getIndustrialCustomerCount()));
        result.setOtherCustomerCount(HzhrTypeUtil.integer2integer(in.getOtherCustomerCount()));
        result.setCreateTime(HzhrTypeUtil.long2date(in.getCardCreateTime()));
        result.setDeviceId(HzhrTypeUtil.integer2integer(in.getDeviceId()));
        return result;
    }
    public DeviceInfoCardEntity regulatorDevice_InfoCardModel2entity(RegulatorDevice_InfoCardModel in, DeviceInfoCardEntity ori) {
        //未转换字段: createUserId updateUserId isValid outId updateTime state 
        if (in == null) return null;
        DeviceInfoCardEntity result = ori;

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setRuningPressure(HzhrTypeUtil.double2double(in.getRuningPressure()));
        result.setMainClosePressure(HzhrTypeUtil.double2double(in.getMainClosePressure()));
        result.setSecondClosePressure(HzhrTypeUtil.double2double(in.getSecondClosePressure()));
        result.setOffPressure(HzhrTypeUtil.double2double(in.getOffPressure()));
        result.setEscapePressure(HzhrTypeUtil.double2double(in.getEscapePressure()));
        result.setSafetyDevice(HzhrTypeUtil.string2string(in.getSafetyDevice()));
        result.setPegCount(HzhrTypeUtil.integer2integer(in.getPegCount()));
        result.setResidentCustomerCount(HzhrTypeUtil.integer2integer(in.getResidentCustomerCount()));
        result.setCommercialCustomerCount(HzhrTypeUtil.integer2integer(in.getCommercialCustomerCount()));
        result.setCollectiveCustomerCount(HzhrTypeUtil.integer2integer(in.getCollectiveCustomerCount()));
        result.setIndustrialCustomerCount(HzhrTypeUtil.integer2integer(in.getIndustrialCustomerCount()));
        result.setOtherCustomerCount(HzhrTypeUtil.integer2integer(in.getOtherCustomerCount()));
        result.setCreateTime(HzhrTypeUtil.long2date(in.getCardCreateTime()));
        result.setDeviceId(HzhrTypeUtil.integer2integer(in.getDeviceId()));
        return result;
    }
    public List<DeviceInfoCardEntity> regulatorDevice_InfoCardModelList2entityList(List<RegulatorDevice_InfoCardModel> in) {
        if (in == null) return null;
        List<DeviceInfoCardEntity> result = new ArrayList<>();
        for (RegulatorDevice_InfoCardModel item : in) {
            result.add(regulatorDevice_InfoCardModel2entity(item));
        }
        return result;
    }
    public RegulatorDevice_InfoCardModel entity2regulatorDevice_InfoCardModel(DeviceInfoCardEntity in) {
        //未转换字段: managementName safetyDeviceDes subCompanyName deptId manageUserName typeId deviceCode manageUserId installAddress typeDes usingDate prodFactoryDes 
        if (in == null) return null;
        RegulatorDevice_InfoCardModel result = new RegulatorDevice_InfoCardModel();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDeviceId(HzhrTypeUtil.integer2integer(in.getDeviceId()));
        result.setRuningPressure(HzhrTypeUtil.double2double(in.getRuningPressure()));
        result.setMainClosePressure(HzhrTypeUtil.double2double(in.getMainClosePressure()));
        result.setSecondClosePressure(HzhrTypeUtil.double2double(in.getSecondClosePressure()));
        result.setOffPressure(HzhrTypeUtil.double2double(in.getOffPressure()));
        result.setEscapePressure(HzhrTypeUtil.double2double(in.getEscapePressure()));
        result.setSafetyDevice(HzhrTypeUtil.string2string(in.getSafetyDevice()));
        result.setPegCount(HzhrTypeUtil.integer2integer(in.getPegCount()));
        result.setResidentCustomerCount(HzhrTypeUtil.integer2integer(in.getResidentCustomerCount()));
        result.setCommercialCustomerCount(HzhrTypeUtil.integer2integer(in.getCommercialCustomerCount()));
        result.setCollectiveCustomerCount(HzhrTypeUtil.integer2integer(in.getCollectiveCustomerCount()));
        result.setIndustrialCustomerCount(HzhrTypeUtil.integer2integer(in.getIndustrialCustomerCount()));
        result.setOtherCustomerCount(HzhrTypeUtil.integer2integer(in.getOtherCustomerCount()));
        result.setCardCreateTime(HzhrTypeUtil.date2long(in.getCreateTime()));
        return result;
    }
    public List<RegulatorDevice_InfoCardModel> entityList2regulatorDevice_InfoCardModelList(List<DeviceInfoCardEntity> in) {
        if (in == null) return null;
        List<RegulatorDevice_InfoCardModel> result = new ArrayList<>();
        for (DeviceInfoCardEntity item : in) {
            result.add(entity2regulatorDevice_InfoCardModel(item));
        }
        return result;
    }
    public RegulatorDevice_InfoCardModel ext2regulatorDevice_InfoCardModel(DeviceInfoCardEntityExt in) {
        //未转换字段: managementName safetyDeviceDes subCompanyName deptId manageUserName typeId deviceCode manageUserId installAddress typeDes usingDate prodFactoryDes 
        if (in == null) return null;
        RegulatorDevice_InfoCardModel result = new RegulatorDevice_InfoCardModel();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDeviceId(HzhrTypeUtil.integer2integer(in.getDeviceId()));
        result.setRuningPressure(HzhrTypeUtil.double2double(in.getRuningPressure()));
        result.setMainClosePressure(HzhrTypeUtil.double2double(in.getMainClosePressure()));
        result.setSecondClosePressure(HzhrTypeUtil.double2double(in.getSecondClosePressure()));
        result.setOffPressure(HzhrTypeUtil.double2double(in.getOffPressure()));
        result.setEscapePressure(HzhrTypeUtil.double2double(in.getEscapePressure()));
        result.setSafetyDevice(HzhrTypeUtil.string2string(in.getSafetyDevice()));
        result.setPegCount(HzhrTypeUtil.integer2integer(in.getPegCount()));
        result.setResidentCustomerCount(HzhrTypeUtil.integer2integer(in.getResidentCustomerCount()));
        result.setCommercialCustomerCount(HzhrTypeUtil.integer2integer(in.getCommercialCustomerCount()));
        result.setCollectiveCustomerCount(HzhrTypeUtil.integer2integer(in.getCollectiveCustomerCount()));
        result.setIndustrialCustomerCount(HzhrTypeUtil.integer2integer(in.getIndustrialCustomerCount()));
        result.setOtherCustomerCount(HzhrTypeUtil.integer2integer(in.getOtherCustomerCount()));
        result.setCardCreateTime(HzhrTypeUtil.date2long(in.getCreateTime()));
        return result;
    }
    public List<RegulatorDevice_InfoCardModel> extList2regulatorDevice_InfoCardModelList(List<DeviceInfoCardEntityExt> in) {
        if (in == null) return null;
        List<RegulatorDevice_InfoCardModel> result = new ArrayList<>();
        for (DeviceInfoCardEntityExt item : in) {
            result.add(ext2regulatorDevice_InfoCardModel(item));
        }
        return result;
    }
    public RegulatorDevice_InfoCardGetModel extList2regulatorDevice_InfoCardGetModel(List<DeviceInfoCardEntityExt> extList, Integer total, Integer changeCount, Map<String, Object> query) {
        List<RegulatorDevice_InfoCardModel> modelList = extList2regulatorDevice_InfoCardModelList(extList);
        if (modelList == null) {
            RegulatorDevice_InfoCardGetModel result = new RegulatorDevice_InfoCardGetModel();
            result.setTotal(total);
            result.setChangeCount(changeCount);
            return result;
        }

         String _show = HzhrTypeUtil.object2string(query.get("_show"));
         Boolean _show_info = query.get("_show_info") != null ? Boolean.parseBoolean(query.get("_show_info").toString()) : false;
         Boolean _show_device = query.get("_show_device") != null ? Boolean.parseBoolean(query.get("_show_device").toString()) : false;

        if (!_show_info) {
            for (RegulatorDevice_InfoCardModel model : modelList) {
                model.setRuningPressure(null);
                model.setMainClosePressure(null);
                model.setSecondClosePressure(null);
                model.setOffPressure(null);
                model.setEscapePressure(null);
                model.setSafetyDevice(null);
                model.setSafetyDeviceDes(null);
                model.setPegCount(null);
                model.setResidentCustomerCount(null);
                model.setCommercialCustomerCount(null);
                model.setCollectiveCustomerCount(null);
                model.setIndustrialCustomerCount(null);
                model.setOtherCustomerCount(null);
                model.setCardCreateTime(null);
            }
        }
        if (!_show_device) {
            for (RegulatorDevice_InfoCardModel model : modelList) {
                model.setDeviceId(null);
                model.setDeviceCode(null);
                model.setDeptId(null);
                model.setManagementName(null);
                model.setSubCompanyName(null);
                model.setManageUserId(null);
                model.setManageUserName(null);
                model.setTypeId(null);
                model.setTypeDes(null);
                model.setInstallAddress(null);
                model.setUsingDate(null);
                model.setProdFactoryDes(null);
            }
        }

        RegulatorDevice_InfoCardGetModel result = new RegulatorDevice_InfoCardGetModel();
        if ("one".equals(_show)) {
            if (modelList.size() > 0) {
                result.setModel(modelList.get(0));
            }
         }
        if ("list".equals(_show)) {
            result.setModelList(modelList);
        }
        result.setTotal(total);
        result.setChangeCount(changeCount);
        return result;
    }
    public RegulatorDevice_InfoCardGetModel entity2regulatorDevice_InfoCardGetModel(DeviceInfoCardEntity entity, Integer total, Integer changeCount, Map<String, Object> query) {
        List<DeviceInfoCardEntityExt> extList = new ArrayList<>();
        if (entity == null) return extList2regulatorDevice_InfoCardGetModel(extList, total, changeCount, query);
        extList.add(HzhrJsonUtil.convertObjectType(entity, DeviceInfoCardEntityExt.class));
        return extList2regulatorDevice_InfoCardGetModel(extList, total, changeCount, query);
     }
    public DeviceInfoCardEntity regulatorDevice_InfoCardPutModel2entity(RegulatorDevice_InfoCardPutModel in) {
        //未转换字段: createUserId createTime updateUserId isValid outId updateTime id state deviceId 
        if (in == null) return null;
        DeviceInfoCardEntity result = new DeviceInfoCardEntity();

        result.setRuningPressure(HzhrTypeUtil.double2double(in.getRuningPressure()));
        result.setMainClosePressure(HzhrTypeUtil.double2double(in.getMainClosePressure()));
        result.setSecondClosePressure(HzhrTypeUtil.double2double(in.getSecondClosePressure()));
        result.setOffPressure(HzhrTypeUtil.double2double(in.getOffPressure()));
        result.setEscapePressure(HzhrTypeUtil.double2double(in.getEscapePressure()));
        result.setSafetyDevice(HzhrTypeUtil.string2string(in.getSafetyDevice()));
        result.setPegCount(HzhrTypeUtil.integer2integer(in.getPegCount()));
        result.setResidentCustomerCount(HzhrTypeUtil.integer2integer(in.getResidentCustomerCount()));
        result.setCommercialCustomerCount(HzhrTypeUtil.integer2integer(in.getCommercialCustomerCount()));
        result.setCollectiveCustomerCount(HzhrTypeUtil.integer2integer(in.getCollectiveCustomerCount()));
        result.setIndustrialCustomerCount(HzhrTypeUtil.integer2integer(in.getIndustrialCustomerCount()));
        result.setOtherCustomerCount(HzhrTypeUtil.integer2integer(in.getOtherCustomerCount()));
        return result;
    }
    public DeviceInfoCardEntity regulatorDevice_InfoCardPutModel2entity(RegulatorDevice_InfoCardPutModel in, DeviceInfoCardEntity ori) {
        //未转换字段: createUserId createTime updateUserId isValid outId updateTime id state deviceId 
        if (in == null) return null;
        DeviceInfoCardEntity result = ori;

        result.setRuningPressure(HzhrTypeUtil.double2double(in.getRuningPressure()));
        result.setMainClosePressure(HzhrTypeUtil.double2double(in.getMainClosePressure()));
        result.setSecondClosePressure(HzhrTypeUtil.double2double(in.getSecondClosePressure()));
        result.setOffPressure(HzhrTypeUtil.double2double(in.getOffPressure()));
        result.setEscapePressure(HzhrTypeUtil.double2double(in.getEscapePressure()));
        result.setSafetyDevice(HzhrTypeUtil.string2string(in.getSafetyDevice()));
        result.setPegCount(HzhrTypeUtil.integer2integer(in.getPegCount()));
        result.setResidentCustomerCount(HzhrTypeUtil.integer2integer(in.getResidentCustomerCount()));
        result.setCommercialCustomerCount(HzhrTypeUtil.integer2integer(in.getCommercialCustomerCount()));
        result.setCollectiveCustomerCount(HzhrTypeUtil.integer2integer(in.getCollectiveCustomerCount()));
        result.setIndustrialCustomerCount(HzhrTypeUtil.integer2integer(in.getIndustrialCustomerCount()));
        result.setOtherCustomerCount(HzhrTypeUtil.integer2integer(in.getOtherCustomerCount()));
        return result;
    }
    public List<DeviceInfoCardEntity> regulatorDevice_InfoCardPutModelList2entityList(List<RegulatorDevice_InfoCardPutModel> in) {
        if (in == null) return null;
        List<DeviceInfoCardEntity> result = new ArrayList<>();
        for (RegulatorDevice_InfoCardPutModel item : in) {
            result.add(regulatorDevice_InfoCardPutModel2entity(item));
        }
        return result;
    }
    public RegulatorDevice_InfoCardPutModel entity2regulatorDevice_InfoCardPutModel(DeviceInfoCardEntity in) {
        //未转换字段: 
        if (in == null) return null;
        RegulatorDevice_InfoCardPutModel result = new RegulatorDevice_InfoCardPutModel();

        result.setRuningPressure(HzhrTypeUtil.double2double(in.getRuningPressure()));
        result.setMainClosePressure(HzhrTypeUtil.double2double(in.getMainClosePressure()));
        result.setSecondClosePressure(HzhrTypeUtil.double2double(in.getSecondClosePressure()));
        result.setOffPressure(HzhrTypeUtil.double2double(in.getOffPressure()));
        result.setEscapePressure(HzhrTypeUtil.double2double(in.getEscapePressure()));
        result.setSafetyDevice(HzhrTypeUtil.string2string(in.getSafetyDevice()));
        result.setPegCount(HzhrTypeUtil.integer2integer(in.getPegCount()));
        result.setResidentCustomerCount(HzhrTypeUtil.integer2integer(in.getResidentCustomerCount()));
        result.setCommercialCustomerCount(HzhrTypeUtil.integer2integer(in.getCommercialCustomerCount()));
        result.setCollectiveCustomerCount(HzhrTypeUtil.integer2integer(in.getCollectiveCustomerCount()));
        result.setIndustrialCustomerCount(HzhrTypeUtil.integer2integer(in.getIndustrialCustomerCount()));
        result.setOtherCustomerCount(HzhrTypeUtil.integer2integer(in.getOtherCustomerCount()));
        return result;
    }
    public List<RegulatorDevice_InfoCardPutModel> entityList2regulatorDevice_InfoCardPutModelList(List<DeviceInfoCardEntity> in) {
        if (in == null) return null;
        List<RegulatorDevice_InfoCardPutModel> result = new ArrayList<>();
        for (DeviceInfoCardEntity item : in) {
            result.add(entity2regulatorDevice_InfoCardPutModel(item));
        }
        return result;
    }
    public RegulatorDevice_InfoCardPutModel ext2regulatorDevice_InfoCardPutModel(DeviceInfoCardEntityExt in) {
        //未转换字段: 
        if (in == null) return null;
        RegulatorDevice_InfoCardPutModel result = new RegulatorDevice_InfoCardPutModel();

        result.setRuningPressure(HzhrTypeUtil.double2double(in.getRuningPressure()));
        result.setMainClosePressure(HzhrTypeUtil.double2double(in.getMainClosePressure()));
        result.setSecondClosePressure(HzhrTypeUtil.double2double(in.getSecondClosePressure()));
        result.setOffPressure(HzhrTypeUtil.double2double(in.getOffPressure()));
        result.setEscapePressure(HzhrTypeUtil.double2double(in.getEscapePressure()));
        result.setSafetyDevice(HzhrTypeUtil.string2string(in.getSafetyDevice()));
        result.setPegCount(HzhrTypeUtil.integer2integer(in.getPegCount()));
        result.setResidentCustomerCount(HzhrTypeUtil.integer2integer(in.getResidentCustomerCount()));
        result.setCommercialCustomerCount(HzhrTypeUtil.integer2integer(in.getCommercialCustomerCount()));
        result.setCollectiveCustomerCount(HzhrTypeUtil.integer2integer(in.getCollectiveCustomerCount()));
        result.setIndustrialCustomerCount(HzhrTypeUtil.integer2integer(in.getIndustrialCustomerCount()));
        result.setOtherCustomerCount(HzhrTypeUtil.integer2integer(in.getOtherCustomerCount()));
        return result;
    }
    public List<RegulatorDevice_InfoCardPutModel> extList2regulatorDevice_InfoCardPutModelList(List<DeviceInfoCardEntityExt> in) {
        if (in == null) return null;
        List<RegulatorDevice_InfoCardPutModel> result = new ArrayList<>();
        for (DeviceInfoCardEntityExt item : in) {
            result.add(ext2regulatorDevice_InfoCardPutModel(item));
        }
        return result;
    }
    public DeviceInfoCardCustomQueryModel regulatorDevice_InfoCardService_query2queryModel(Map<String, Object> query) {
        DeviceInfoCardCustomQueryModel queryModel = new DeviceInfoCardCustomQueryModel();

        Integer _equal_id = HzhrTypeUtil.object2integer(query.get("_equal_id"));
        if (_equal_id != null) {
            queryModel.setEqual_id(_equal_id);
         }

        Boolean _show_info = HzhrTypeUtil.object2boolean(query.get("_show_info"));
        if (_show_info != null && _show_info) {
            queryModel.setShow(true);
            queryModel.setShow(true);
            queryModel.setShow(true);
            queryModel.setShow(true);
            queryModel.setShow(true);
            queryModel.setShow(true);
            queryModel.setExt_safetyDeviceExt(true);
            queryModel.setShow23(true);
            queryModel.setShow(true);
            queryModel.setShow(true);
            queryModel.setShow(true);
            queryModel.setShow(true);
            queryModel.setShow(true);
            queryModel.setShow(true);
            queryModel.setShow(true);
        }
        Boolean _show_device = HzhrTypeUtil.object2boolean(query.get("_show_device"));
        if (_show_device != null && _show_device) {
            queryModel.setShow(true);
            queryModel.setExt_deviceExt(true);
            queryModel.setShow20(true);
            queryModel.setExt_deviceExt(true);
            queryModel.setShow20(true);
            queryModel.setExt_deviceExt(true);
            queryModel.setShow20(true);
            queryModel.setExt_deviceExt(true);
            queryModel.setShow20(true);
            queryModel.setExt_deviceExt(true);
            queryModel.setShow20(true);
            queryModel.setExt_deviceExt_typeExt(true);
            queryModel.setShow1(true);
            queryModel.setExt_deviceExt(true);
            queryModel.setShow20(true);
            queryModel.setExt_deviceExt(true);
            queryModel.setShow20(true);
            queryModel.setExt_deviceExt(true);
            queryModel.setShow20(true);
        }

        Integer page = HzhrTypeUtil.object2integer(query.get("_page"));
        Integer count = HzhrTypeUtil.object2integer(query.get("_count"));
        queryModel.setPage(page, count);

        return queryModel;
    }

}

